package com.hrp.analyzer.core.model;

import com.hrp.analyzer.model.Verifiable;
import com.hrp.analyzer.util.SerializationUtils;
import com.hrp.analyzer.util.uri.UrlUtils;

import java.io.Serializable;


/**
 * 解析规则
 *
 * @author hrp
 * @date 2020/12/20 6:44 下午
 */

public class AnalyzerRule implements Serializable, Verifiable {
    private static final long serialVersionUID = -5141682318667696007L;
    /**
     * 网址名称
     */
    private String name;
    /**
     * 网站域名
     */
    private String site;
    /**
     * 分组
     */
    private String group;
    /**
     * 启用
     */
    private Boolean enabled = true;
    /**
     * 是否为文本小说
     */
    private Boolean audio = false;
    /**
     * 权重(越高优先被搜索)
     */
    private int weight = 0;
    /**
     * 默认全局参数
     */
    private Params params = new Params();
    /**
     * 正文
     */
    private ContentRule content = new ContentRule();
    /**
     * 目录规则
     */
    private TocRule toc = new TocRule();
    /**
     * 小说详情信息规则，针对目录页面获取详情
     */
    private DetailRule detail = new DetailRule();
    /**
     * 搜索规则
     */
    private SearchRule search = new SearchRule();

    @Override
    public boolean isEffective() {
        return UrlUtils.isHttpUrl(site);
    }

    /**
     * 深克隆
     *
     * @return 规则克隆对象
     */
    public AnalyzerRule copy() {
        return SerializationUtils.deepClone(this);
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSite() {
        return site;
    }

    public void setSite(String site) {
        this.site = site;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public Boolean getAudio() {
        return audio;
    }

    public void setAudio(Boolean audio) {
        this.audio = audio;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public Params getParams() {
        return params;
    }

    public void setParams(Params params) {
        this.params = params;
    }

    public ContentRule getContent() {
        return content;
    }

    public void setContent(ContentRule content) {
        this.content = content;
    }

    public TocRule getToc() {
        return toc;
    }

    public void setToc(TocRule toc) {
        this.toc = toc;
    }

    public DetailRule getDetail() {
        return detail;
    }

    public void setDetail(DetailRule detail) {
        this.detail = detail;
    }

    public SearchRule getSearch() {
        return search;
    }

    public void setSearch(SearchRule search) {
        this.search = search;
    }
}
